//
//  STCirculationCell.swift
//  iPhone
//
//  Created by Toj on 6/15/22.
//

import UIKit

class STCirculationCell: UICollectionViewCell {
    var model: FloatADModel? {
        didSet {
            // print("materials: " + (model?.materials ?? "" ))
            guard let model = model else {
                return
            }
            let url = URL(string: model.materials)
            
            imageView.kf.setImage(with: url, placeholder: UIImage(named: model.placeholder))
        }
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setupAddSubviews()
    }
    
    required init?(coder: NSCoder) {
        super.init(coder: coder)
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        
        setupMakeLayoutSubviews()
    }
    
    private lazy var imageView: UIImageView = {
        let view = UIImageView()
        return view
    }()
}

extension STCirculationCell {
    
    private func setupAddSubviews() {
        contentView.addSubview(imageView)
    }
    
    private func setupMakeLayoutSubviews() {
        imageView.snp.makeConstraints { make in
            make.edges.equalTo(contentView)
        }
    }
}
